<template>
    <section class="withdraw-ser-info-main base-main">
      <van-cell-group>
        <van-field
          v-model="userName"
          placeholder="姓名"
          label="姓名"
          :error-message="userNameErrorMessage"/>
        <van-field
          v-model="idCard"
          placeholder="身份证号"
          label="身份证号"
          @blur="verifyIdCard"
          :error-message="idCardErrorMessage"/>
        <van-field
          v-model="phoneNum"
          type="number"
          placeholder="手机号"
          label="手机号"
          @blur="verifyPhoneNum"
          :error-message="phoneNumErrorMessage"/>
      </van-cell-group>

      <div class="pop-text-box color7A7B82 fs13">
        <p>温馨提示：合伙人需提供增值税专用票 </p>
        <p>邮寄地址：广州市花都区迎宾大道116号索弗2F，邓晓君 13580491321</p>
      </div>

      <p class="sub-btn text-c">
        <span class="base-btn inline-block" @click="handleSub">确认提交</span>
      </p>
    </section>
</template>

<script type="text/ecmascript-6">
  import api from '../../http/api'

  export default {
    data() {
      return {
        userName:'',//用户名
        userNameErrorMessage:'',//错误提示
        idCard:'',//身份证号
        idCardErrorMessage:'',//错误提示
        isIdCard:false,
        phoneNum:'',//手机号
        phoneNumErrorMessage:'',//错误提示
        isPhoneNum:false,
      }
    },
    methods: {
      //验证身份证
      verifyIdCard(){
        let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        if(reg.test(this.idCard) === false){
          this.idCardErrorMessage = "身份证输入不合法";
          this.isIdCard = false;
        }else{
          this.isIdCard = true;
          this.idCardErrorMessage = "";
        }
      },
      //验证手机号
      verifyPhoneNum(){
        let reg = /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/;
        if(reg.test(this.phoneNum) === false){
          this.phoneNumErrorMessage = "请填写正确号码";
          this.isPhoneNum = false;
        }else{
          this.isPhoneNum = true;
          this.phoneNumErrorMessage = "";
        }
      },
      //确认提现
      handleSub(){
        if(this.userName == ""){
          this.userNameErrorMessage = '请填写姓名';
          return false;
        }else if(!this.isIdCard){
          this.idCardErrorMessage = "身份证输入不合法";
          return false;
        }else if(!this.isPhoneNum){
          this.phoneNumErrorMessage = "请填写正确号码";
          return false;
        }else{
//          this.$ajax({
//            url:api.,
//            method:'post'
//          },{
//
//          })then(res => {
//
//          })
        }
      },
    },
  }
</script>

<style scoped lang="scss">
  @import '../../assets/css/withdrawUserInfo.scss';
</style>
